import Vue from 'vue'
import Vuex from 'vuex'

import user from './user'

import session from '@/libs/session'

Vue.use(Vuex)

const store = new Vuex.Store({
    modules: {
        user
    },
    state: {
        isLogin: false
    },
    mutations: {
        setIsLogin(state, b) {
            state.isLogin = b
        }
    },
    actions: {
        appLaunch({dispatch}) {
            session.isOnline() && dispatch('user/profile')
        }
    }
})

export default store
